package com.yidu.ruifeng_logistics.service.impl;

import com.yidu.ruifeng_logistics.entity.LogisticsPrice;
import com.yidu.ruifeng_logistics.dao.LogisticsPriceDao;
import com.yidu.ruifeng_logistics.service.LogisticsPriceService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 价格表(LogisticsPrice)表服务实现类
 *
 * @author 周有
 * @since 2021-03-11 15:16:44
 */
@Service("logisticsPriceService")
public class LogisticsPriceServiceImpl implements LogisticsPriceService {
    @Resource
    private LogisticsPriceDao logisticsPriceDao;

    /**
     * 通过ID查询单条数据
     *
     * @param priceId 主键
     * @return 实例对象
     */
    @Override
    public LogisticsPrice queryById(Integer priceId) {
        return this.logisticsPriceDao.queryById(priceId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<LogisticsPrice> queryAllByLimit(int offset, int limit) {
        return this.logisticsPriceDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param logisticsPrice 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsPrice insert(LogisticsPrice logisticsPrice) {
        this.logisticsPriceDao.insert(logisticsPrice);
        return logisticsPrice;
    }

    /**
     * 修改数据
     *
     * @param logisticsPrice 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsPrice update(LogisticsPrice logisticsPrice) {
        this.logisticsPriceDao.update(logisticsPrice);
        return this.queryById(logisticsPrice.getPriceId());
    }

    /**
     * 通过主键删除数据
     *
     * @param priceId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer priceId) {
        return this.logisticsPriceDao.deleteById(priceId) > 0;
    }

    @Override
    public List<LogisticsPrice> queryAll(LogisticsPrice logisticsPrice) {
        return this.logisticsPriceDao.queryAll(logisticsPrice);
    }

    @Override
    public int deleteAll(String ids) {
        String[] s = ids.split(",");
        return logisticsPriceDao.deleteAll(s);
    }


}
